/*
* This file is a part of the open-eBackup project.
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at
* http://mozilla.org/MPL/2.0/.
*
* Copyright (c) [2024] Huawei Technologies Co.,Ltd.
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*/
#ifndef RESTORE_HANDLER_H
#define RESTORE_HANDLER_H
#include "common/JsonHelper.h"
#include "BackintConst.h"

namespace backint {
class RestoreHandler {
public:
    RestoreHandler();
    ~RestoreHandler()
    {}
    uint32_t ExecRestore(const StuParam &inParam, const PlugParams &plugParam);
private:
    void GetRestoreParam(const StuParam &inParam, const PlugParams &plugParam);
    std::string GetFileName(const std::string &filePath);
    uint32_t WriteDataToFile(const std::string &inputFile, const std::string &outputFile);
    void ReadWriteData(const StuParam &inParam, const StuFileInfo &fileInfo, const std::string type = "data");
    uint32_t DataRestore(const StuParam &inParam, const StuFileInfo &stFileInfo);
    uint32_t RestoreResult();
private:
    std::string m_pid;
    std::string m_jobId;
    std::string m_subJobId;
    std::string m_dbName;
    std::string m_cachePath;
    std::string m_dataPath;
    std::string m_backupID;
    std::string m_outputFile;
    std::string m_resultFile;
    std::vector<std::string> m_outputResult;
    Json::Value m_outputValue;
    int m_threadCount = 0;
    bool m_restoreResult = true;
    std::mutex m_writeOutFileMutex;
};
}
#endif